home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / sw / resources.c++ < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  6.7 KB  |  245 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include "resources.h"
  18.  
  19. struct AppData {
  20.   public:
  21.     char*    redName;
  22.     char*    greenName;
  23.     char*    blueName;
  24.     char*    purpleName;
  25.     char*    laserName;
  26.     char*    missileName;
  27.  
  28.     // ship class names
  29.     char*    regularName;
  30.  
  31.     // data file directories
  32.     char*    explosionDir;
  33.     char*    soundDir;
  34.     char*    helpFile;
  35. };
  36.  
  37. static int        resourcesLoaded = FALSE;
  38. static AppData        swData;
  39. static XtResource    swResources[] = {
  40.                 { "redName", "RedName",
  41.                   XmRString, sizeof(char*),
  42.                   XtOffsetOf(AppData, redName),
  43.                   XmRString, "Red" },
  44.                 { "greenName", "GreenName",
  45.                   XmRString, sizeof(char*),
  46.                   XtOffsetOf(AppData, greenName),
  47.                   XmRString, "Green" },
  48.                 { "blueName", "BlueName",
  49.                   XmRString, sizeof(char*),
  50.                   XtOffsetOf(AppData, blueName),
  51.                   XmRString, "Blue" },
  52.                 { "purpleName", "PurpleName",
  53.                   XmRString, sizeof(char*),
  54.                   XtOffsetOf(AppData, purpleName),
  55.                   XmRString, "Purple" },
  56.                 { "laserName", "LaserName",
  57.                   XmRString, sizeof(char*),
  58.                   XtOffsetOf(AppData, laserName),
  59.                   XmRString, "Laser" },
  60.                 { "missileName", "MissileName",
  61.                   XmRString, sizeof(char*),
  62.                   XtOffsetOf(AppData, missileName),
  63.                   XmRString, "Missile" },
  64.                 { "explosionDirectory", "ExplosionDirectory",
  65.                   XmRString, sizeof(char*),
  66.                   XtOffsetOf(AppData, explosionDir),
  67.    /* stuff added by ratman, 2/24/94 for relative cwd && input file paths */
  68.                   /*
  69.                   uncomment the following and comment the
  70.                   active line below if you want to access
  71.                   the help file from the default location
  72.                   under "/usr/src/IndigoGames..."
  73.                   XmRString, "." },
  74.                   */
  75.                   XmRString, "../data/sw/" },
  76.                 { "soundDirectory", "SoundDirectory",
  77.                   XmRString, sizeof(char*),
  78.                   XtOffsetOf(AppData, soundDir),
  79.    /* stuff added by ratman, 2/24/94 for relative cwd && input file paths */
  80.                   /*
  81.                   uncomment the following and comment the
  82.                   active line below if you want to access
  83.                   the help file from the default location
  84.                   under "/usr/src/IndigoGames..."
  85.                   XmRString, "." },
  86.                   */
  87.                   XmRString, "../data/sw/" },
  88.                 { "helpFile", "HelpFile",
  89.                   XmRString, sizeof(char*),
  90.                   XtOffsetOf(AppData, helpFile),
  91.    /* stuff added by ratman, 2/24/94 for relative cwd && input file paths */
  92.                   /*
  93.                   uncomment the following and comment the
  94.                   active line below if you want to access
  95.                   the help file from the default location
  96.                   under "/usr/src/IndigoGames..."
  97.                   XmRString, "/usr/src/IndigoGames/IndiZone/sw/sw.hlp" },
  98.                   */
  99.                   XmRString, "../data/sw/swHelp.showcase" },
  100.  
  101.                 { "regularName", "RegularName",
  102.                   XmRString, sizeof(char*),
  103.                   XtOffsetOf(AppData, regularName),
  104.                   XmRString, "Regular" }
  105.                 };
  106. static char*        fallbacks[] = {
  107.             "*label*fontList: -*-helvetica-bold-r-normal-*-14-*",
  108.             "*info*fontList: -*-helvetica-medium-r-normal-*-14-*",
  109.             "*XmPushButton*fontList: -*-helvetica-medium-r-normal-*-14-*",
  110.             "*XmPushButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14-*",
  111.             "*XmToggleButton*fontList: -*-helvetica-medium-r-normal-*-14-",
  112.             "*XmToggleButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14-*",
  113.             "*XmPushButton*marginHeight:     4",
  114.             "*XmPushButton*marginWidth:     7",
  115.             "*XmToggleButtonGadget*spacing: 4",
  116.             "*XmToggleButton*spacing:     4",
  117.             "*XmText*marginHeight:       4",
  118.             "*foreground:            Black",
  119.             "*background:            #c1c1c1",
  120.             "*highlightThickness:        0",
  121.             "*fillOnSelect:            True",
  122.             "*visibleWhenOff:        True",
  123.             "*selectColor:            #ffff00",
  124.             "*XmText.background:        #999999",
  125.             "*status*fractionBase:        10",
  126.             "*status*rightPosition:        3",
  127.             "*weapons*label.labelString:    Weapons:",
  128.             "*shields*label.labelString:    Shields:",
  129.             "*laser*label.labelString:    Laser:",
  130.             "*missile*label.labelString:    Missiles:",
  131.             "*thrust*label.labelString:    Thrust:",
  132.             "*fuel*label.labelString:    Fuel:",
  133.             "*radio*label.labelString:    Radio:",
  134.             "*radio*off.labelString:    Off",
  135.             "*radio*team.labelString:    Team",
  136.             "*radio*all.labelString:    All",
  137.             "*sound*label.labelString:    Sound:",
  138.             "*sound*off.labelString:    Off",
  139.             "*sound*warning.labelString:    Warn",
  140.             "*sound*all.labelString:    All",
  141.             "*radar*label.labelString:    Radar:",
  142.             "*target*label.labelString:    Target:",
  143.             "*message*label.labelString:    Messages:",
  144.             "*score*label.labelString:    Score:",
  145.             "*players*label.labelString:    Players:",
  146.             "*flag*label.labelString:    Flag:",
  147.             "*pause.labelString:        Pause",
  148.             "*help.labelString:        Help",
  149.             "*quit.labelString:        Quit",
  150.             NULL };
  151.  
  152. void            setFallbacks(XtAppContext context)
  153. {
  154.   XtAppSetFallbackResources(context, fallbacks);
  155. }
  156.  
  157. void            loadResources(Widget top)
  158. {
  159.   if (resourcesLoaded) return;
  160.   XtVaGetApplicationResources(top, (XtPointer)&swData,
  161.                 swResources, XtNumber(swResources), NULL);
  162. }
  163.  
  164. char*            weaponName(Weapon w)
  165. {
  166.   switch (w) {
  167.     case Laser: return swData.laserName;
  168.     case Missile: return swData.missileName;
  169.   }
  170.   return NULL;
  171. }
  172.  
  173. char*            teamName(Team t)
  174. {
  175.   switch (t) {
  176.     case NoTeam: return "nil";
  177.     case RedTeam: return swData.redName;
  178.     case GreenTeam: return swData.greenName;
  179.     case BlueTeam: return swData.blueName;
  180.     case PurpleTeam: return swData.purpleName;
  181.   }
  182.   return NULL;
  183. }
  184.  
  185. long            teamColor(Team t)
  186. {
  187.   switch (t) {
  188.     case NoTeam: return 0xff000000;
  189.     case RedTeam: return 0xff0000ff;
  190.     case GreenTeam: return 0xff00ff00;
  191.     case BlueTeam: return 0xffff0000;
  192.     case PurpleTeam: return 0xffff00ff;
  193.   }
  194.   return 0xff000000;
  195. }
  196.  
  197. float*            teamColor(Team t, float i)
  198. {
  199.   static float c[3];
  200.  
  201.   switch (t) {
  202.     case RedTeam:
  203.     c[0] = i; c[1] = c[2] = 0.0;
  204.     break;
  205.     case GreenTeam:
  206.     c[1] = i; c[0] = c[2] = 0.0;
  207.     break;
  208.     case BlueTeam:
  209.     c[2] = i; c[0] = c[1] = 0.0;
  210.     break;
  211.     case PurpleTeam:
  212.     c[0] = c[2] = i; c[1] = 0.0;
  213.     break;
  214.     default:
  215.     case NoTeam:
  216.     c[0] = c[1] = c[2] = i;
  217.     break;
  218.   }
  219.   return c;
  220. }
  221.  
  222. char*            shipClassName(ShipClass c)
  223. {
  224.   switch (c) {
  225.     case ShipClassRegular:
  226.     return swData.regularName;
  227.   }
  228.   return "???";
  229. }
  230.  
  231. char*            explosionDirectory()
  232. {
  233.   return swData.explosionDir;
  234. }
  235.  
  236. char*            soundsDirectory()
  237. {
  238.   return swData.soundDir;
  239. }
  240.  
  241. char*            helpFile()
  242. {
  243.   return swData.helpFile;
  244. }
  245.